/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package optinsa;

import java.util.ArrayList;

/**
 *
 * @author falxa
 */
public class Job {
    
    private int id;
    private ArrayList<Task> tasks;
    private int date;
    
    public Job(int i)
    {
        this.id = i;
        this.tasks = new ArrayList<>();
        this.date = 0;
    }

    public int getID() 
    {
        return id;
    }
    
    public int getDate() {
        return date;
    }

    public void setDate(int date) {
        this.date = date;
    }
    
    public void addTask(Task t)
    {
        t.setEarlydate(this.date);
        this.date += t.getDuration();
        this.tasks.add(t);
    }
    
    public ArrayList<Task> getTasks()
    {
        return this.tasks;
    }
    
    public void print()
    {
        String s = "JOB"+this.id+": ";
        for (int i=0; i<tasks.size(); i++)
            s += tasks.get(i)+" ";
        System.out.println(s);
    }
    
    public void printState()
    {
        for (int i=0; i<tasks.size(); i++)
            tasks.get(i).printTask();
        System.out.println("");
    }

    public boolean prevDone(int t) 
    {
        boolean res = false;
        if (t == 0) res = true;
        else res = this.tasks.get(t-1).isDone();
        return res;
    }
    
}
